package kosta.model.board;

import java.sql.SQLException;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

@Service
public class QnABoardServiceImpl implements QnABoardService{
	@Resource(name="qnABoardDaoImpl")
	private BoardDao boardDao;

	@Override
	public List<BoardVO> getListBoard() throws SQLException {
		return boardDao.getListBoard();
	}

	@Override
	public BoardVO findByNo(int no) throws SQLException {
		boardDao.updateCount(no); // 조회수 증가
		return boardDao.findByNo(no);
	}

	@Override
	public int insertBoard(BoardVO bvo) throws SQLException {
		boardDao.pointMinus(bvo.getMemberVO().getId());
		 return boardDao.insertBoard(bvo);
	}

	@Override
	public void updateBoard(BoardVO bvo) throws SQLException {
		 boardDao.updateBoard(bvo);
	}

	@Override
	public void deleteBoard(int no, String id) throws SQLException {
		boardDao.deleteBoard(no);	
	}

	@Override
	public BoardVO noCountView(int no) throws SQLException {
		return boardDao.findByNo(no);
	}

	@Override
	public List<BoardVO> findById(String id) throws SQLException {
		//System.out.println("ID service: "+id);
		//System.out.println(boardDao.findById(id));
		return boardDao.findById(id);
	}

	@Override
	public List<BoardVO> findByTitle(String title) throws SQLException {
		return boardDao.findByTitle(title);
	}

	@Override
	public void checkAdopt(int no) throws SQLException {
		boardDao.checkAdopt(no);
	}

	@Override
	public void pointMinus(String id) throws SQLException {
		boardDao.pointMinus(id);
	}
	
	
	////관리자 글이동

	@Override
	public int moveBoard(BoardVO bvo) throws Exception {
		return boardDao.moveBoard(bvo);
	}

	@Override
	public BoardVO findByRand() throws Exception {
		return boardDao.findByRand();
	}
}
